package com.rran.study.designpattern.behavioral.mediator.mediator;

import com.rran.study.designpattern.behavioral.mediator.colleague.Hourse;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yy
 * @Type HourseMediator.java
 * @Desc 房产中介
 * @date 2020/7/23 16:44
 */
public class HourseMediator implements Mediator {

    private List<Hourse> hourses = new ArrayList<>();

    public void register(Hourse hourse){
        if(!hourses.contains(hourse)){
            hourses.add(hourse);
            hourse.setMediator(this);
        }
    }


    @Override
    public void sendMessage(Hourse hourse,Long upPrice) {
        for(Hourse h: hourses){
            if(!h.equals(hourse)){
                h.followUpPrice(upPrice);
            }
        }
    }
}
